#include "../Tools/GLHeaders.hpp"
#include "Obj2.hpp"
#include <cmath>

void Obj2::Draw(void){
	glPushAttrib(GL_COLOR_BUFFER_BIT|GL_CURRENT_BIT|GL_TEXTURE_BIT);	
	glDisable(GL_TEXTURE_2D); 
	if(activate)
		glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	else
		glColor4f(0.0f, 1.0f, 0.0f, 1.0f);

	glCallList(list_id);
	glPopAttrib();
}

void Obj2::Activate(void){
	activate = true;
}

void Obj2::Desactivate(void){
	activate = false;
}

Obj2::Obj2(void){ 
	list_id = glGenLists(1); // create one DisplayList
	glNewList(list_id, GL_COMPILE);
	glLineWidth(2);
	glBegin(GL_LINES);
	glVertex3f( 0.0f, 0.0f, 0.0f);
	glVertex3f(-4.0f, 0.0f, 0.0f);
	glVertex3f(-4.0f,-0.5f, 0.0f);
	glVertex3f(-4.0f, 0.5f, 0.0f);
	glEnd();
	glEndList();
}

Obj2::~Obj2(void){
	glDeleteLists(list_id,1);
}

